package com.woniu01;

import java.io.*;

public class Test01 {
    public static void main(String[] args) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("a.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("b.txt"));
        byte[] buf = new byte[1024];
        int len;
        while ((len = bis.read(buf)) > -1) {
            bos.write(buf, 0, len);
        }
        bis.close();
        bos.close();
    }

    private static void test03() throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("a.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("b.txt"));
        int len;
        while((len = bis.read()) != -1){
            bos.write(len);
        }
        bis.close();
        bos.close();
    }

    private static void test02() throws IOException {
        FileInputStream fis = new FileInputStream("a.txt");
        FileOutputStream fos = new FileOutputStream("b.txt");
        int len;
        while((len = fis.read()) != -1){
            fos.write(len);
        }
        fis.close();
        fos.close();
    }

    private static void test01() throws IOException {
        FileInputStream fis = new FileInputStream("a.txt");
        FileOutputStream fos = new FileOutputStream("b.txt");
        byte[] buf = new byte[1024];
        int len;
        while ((len = fis.read(buf)) > -1) {
            fos.write(buf, 0, len);
        }
        fis.close();
        fos.close();
    }
}
